Inventory

The Inventory Meta for the Grid Inventory Module.

Functions

inventoryMeta:add(itemTypeOrItem, xOrQuantity, yOrData, noReplicate)

Adds an item to the inventory. Handles both adding a single item or stacking multiple items if applicable.

Parameters

  • itemTypeOrItem

    The type of the item or the item object to add.

  • xOrQuantity

    The X position in the grid or the quantity of items to add.

  • yOrData

    The Y position in the grid or additional data for the item.

  • noReplicate Boolean default: false

    If true, the addition will not be replicated to clients.

Returns

  • deferred

    A deferred object that resolves when the item is added.

inventoryMeta:canItemFitInInventory(item, x, y)

Checks if an item can fit in the inventory at a given position.

Parameters

  • item

    The item to check.

  • x Integer

    The X position in the inventory grid.

  • y Integer

    The Y position in the inventory grid.

Returns

  • boolean

    Whether the item can fit in the inventory.

inventoryMeta:configure()

Configures the inventory with specific access rules.

inventoryMeta:doesFitInventory(item)

Checks if an item can fit in the inventory, including within bags.

Parameters

  • item

    The item to check.

Returns

  • boolean

    Whether the item can fit in the inventory.

inventoryMeta:doesItemFitAtPos(testItem, x, y)

Checks if an item fits at a specific position in the inventory.

Parameters

  • testItem

    The item to check.

  • x Integer

    The X position in the inventory grid.

  • y Integer

    The Y position in the inventory grid.

Returns

  • boolean

    Whether the item fits at the given position.

  • item

    The item it overlaps with, if any.

inventoryMeta:doesItemOverlapWithOther(testItem, x, y, item)

Checks if an item overlaps with another item in the inventory.

Parameters

  • testItem

    The item to test for overlap.

  • x Integer

    The X position of the test item in the inventory grid.

  • y Integer

    The Y position of the test item in the inventory grid.

  • item

    The item to check against.

Returns

  • boolean

    Whether the test item overlaps with the given item.

inventoryMeta:findFreePosition(item)

Finds a free position in the inventory where an item can fit.

Parameters

  • item

    The item to find a position for.

Returns

  • int

    The X position in the inventory grid.

  • int

    The Y position in the inventory grid.

inventoryMeta:getHeight()

Retrieves the height of the inventory grid.

Returns

  • integer

    The height of the inventory grid.

inventoryMeta:getItems(noRecurse)

Retrieves all items in the inventory.

Parameters

  • noRecurse Boolean default: false

    Whether to include items inside bags (nested inventories).

Returns

  • table

    A table of all items in the inventory.

inventoryMeta:getSize()

Retrieves the size (width and height) of the inventory grid.

Returns

  • integer

    The width of the inventory grid.

  • integer

    The height of the inventory grid.

inventoryMeta:getWidth()

Retrieves the width of the inventory grid.

Returns

  • integer

    The width of the inventory grid.

inventoryMeta:remove(itemTypeOrID, quantity)

Removes an item or a quantity of items from the inventory.

Parameters

  • itemTypeOrID

    The type of the item or its ID to remove.

  • quantity Integer default: 1

    The quantity of items to remove.

Returns

  • deferred

    A deferred object that resolves when the item is removed.

inventoryMeta:requestTransfer(itemID, destinationID, x, y)

Requests a transfer of an item to another inventory.

Parameters

  • itemID Integer

    The ID of the item to transfer.

  • destinationID Integer

    The ID of the destination inventory.

  • x Integer

    The X position in the destination grid.

  • y Integer

    The Y position in the destination grid.

inventoryMeta:setOwner(owner, fullUpdate)

Sets the owner of the inventory. If the owner is a player, it sets the inventory's owner to the player's character ID.

Parameters

  • owner

    The new owner of the inventory (Player or number).

  • fullUpdate Boolean default: false

    Whether to sync the inventory to the client.

inventoryMeta:setSize(w, h)

Sets the size of the inventory grid.

Parameters

  • w Integer

    The width of the grid.

  • h Integer

    The height of the grid.

inventoryMeta:wipeItems()

Removes all items from the inventory.